<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Demo</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/handsontable/8.3.2/handsontable.full.min.js"></script>
    <link href="https://cdn.bootcdn.net/ajax/libs/handsontable/8.3.2/handsontable.full.min.css" rel="stylesheet">
</head>

<body>
    <p style="text-align:center;">
        <input style="font-size:16px;" type="file" id="demo-file" name="Luckyexcel-demo-file" />
    </p>
    <div id="handson"></div>
    <script>
        $(function () {
            const container = document.getElementById('handson');
            window.hot = new Handsontable(container, {
                width: $(window).innerWidth() - 100,
                height: $(window).innerHeight() - 100,
                licenseKey: 'non-commercial-and-evaluation',
            });
            $('#demo-file').change(demoHandler)
        })
    </script>
    <script src='dist/test.js'></script>
    <script>
        function demoHandler(event) {
            var files = event.target.files;
            if (files == null || files.length === 0) {
                alert("No files wait for import");
                return;
            }

            let name = files[0].name;
            let suffixArr = name.split("."), suffix = suffixArr[suffixArr.length - 1];
            if (suffix != "xlsx") {
                alert("Currently only supports the import of xlsx files");
                return;
            }
            xlsx2handson(files[0]).then(option => { console.log(option); window.hot.updateSettings(option[0]) })
        }
    </script>
</body>

</html>
